import requests
import time
import execjs

cookies = {
    'HMACCOUNT': '9F47B428D92F550C',
    'Hm_lvt_9bcbda9cbf86757998a2339a0437208e': '1720709647',
    'no-alert3': 'true',
    'Hm_lvt_c99546cf032aaa5a679230de9a95c7db': '1720709646,1720793980',
    'm': '9b3590f7b28c919a5a845a151b1c121a|1720952574000',
    'yuanrenxue_cookie': '1720965300|JQ8SJBkPFeJL7OCgwUYZUCW0jY22EhxzRq0RbGfgYkhLsWA9p71Qv9HmjTX0vnWxWUdtzCyIJ7op4UVQf8E8E8o0UExhND6pXVQpOvsOXFFwd5sWwlHyP00ljZfk80O8GKauGSYgPDNIMZLY2w7H',
    'tk': '-1684111532222406585',
    'sessionid': '66qea2qj2vdsde1g9dbzgf0tx7u8dmgq',
    'Hm_lpvt_9bcbda9cbf86757998a2339a0437208e': '1721403634',
    'Hm_lpvt_c99546cf032aaa5a679230de9a95c7db': '1721452697',
}

headers = {
    'authority': 'match.yuanrenxue.cn',
    'accept': 'application/json, text/javascript, */*; q=0.01',
    'accept-language': 'zh-CN,zh;q=0.9',
    # 'cookie': 'HMACCOUNT=9F47B428D92F550C; Hm_lvt_9bcbda9cbf86757998a2339a0437208e=1720709647; no-alert3=true; Hm_lvt_c99546cf032aaa5a679230de9a95c7db=1720709646,1720793980; m=9b3590f7b28c919a5a845a151b1c121a|1720952574000; yuanrenxue_cookie=1720965300|JQ8SJBkPFeJL7OCgwUYZUCW0jY22EhxzRq0RbGfgYkhLsWA9p71Qv9HmjTX0vnWxWUdtzCyIJ7op4UVQf8E8E8o0UExhND6pXVQpOvsOXFFwd5sWwlHyP00ljZfk80O8GKauGSYgPDNIMZLY2w7H; tk=-1684111532222406585; sessionid=66qea2qj2vdsde1g9dbzgf0tx7u8dmgq; Hm_lpvt_9bcbda9cbf86757998a2339a0437208e=1721403634; Hm_lpvt_c99546cf032aaa5a679230de9a95c7db=1721452697',
    'referer': 'https://match.yuanrenxue.cn/match/16',
    'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"macOS"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
    'x-requested-with': 'XMLHttpRequest',
}

params = {
    'page': '1',
    'm': 'G4dSpY5Cf5Zmedte5f4177db3e0b8789cb16cba0dd17af2YSpKKeiWWT',
    't': str(round(time.time())*1000),
}

ctx = execjs.compile(open('./code.js', 'r', encoding='utf-8').read())

def solution():
    result = 0
    for i in range(1, 6):
        params['page'] = str(i)
        params['t'] = str(round(time.time())*1000)
        params['m'] = ctx.call('get_m', params['t'])
        print(params)

        response = requests.get('https://match.yuanrenxue.cn/api/match/16', params=params, cookies=cookies, headers=headers, verify=False)
        response = response.json()
        for item in response['data']:
            result += item['value']
    return result


if __name__ == '__main__':
    print(solution())